<template>
  <div>
    <van-nav-bar title="收货地址">
      <template #left>
        <van-icon
          name="arrow-left"
          size=".6rem"
          @click="$router.back()"
          color="grey"
        />
      </template>
      <template #right>
        <van-icon name="ellipsis" size=".6rem" color="grey" />
      </template>
    </van-nav-bar>

    <van-address-list
      v-model="chosenAddressId"
      :list="list"
      default-tag-text="默认"
      @add="onAdd"
      @edit="onEdit"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      chosenAddressId: "1",
      list: [
        {
          id: "1",
          name: "张三",
          tel: "13000000000",
          province: "浙江省",
          city: "杭州市",
          county: "西湖区",
          addressDetail: "文三路 138 号东方通信大厦 7 楼 501 室",
          address: "浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室",
          isDefault: true,
        },
        {
          id: "2",
          name: "李四",
          tel: "1310000000",
          province: "浙江省",
          city: "杭州市",
          county: "拱墅区",
          addressDetail: "莫干山路 50 号",
          address: "浙江省杭州市拱墅区莫干山路 50 号",
        },
      ],
    };
  },
  methods: {
    onAdd() {
      location.href = "#/user/addaddr";
    },
    onEdit(item) {
      location.href = "#/user/editaddr";
      localStorage.setItem("useraddr", JSON.stringify(item));
    },
  },
};
</script>

<style>
</style>